/** 跨平台定义，主要是定义windows/linux下能通用的函数和类型
 * @file platform.h
 * @author Kiven Lee
 * @version 1.0
 * @date 2021-08-08
 *
 * @copyright Copyright Kivensoft (c) 2021
 *
 */
#pragma once
#ifndef __PLATFORM_H__
#define __PLATFORM_H__

#ifdef _WIN32
#   include <winsock2.h>
#   include <windows.h>
#endif

#if defined(__clang__) || defined(__GNUC__)
#   define CPP_STANDARD __cplusplus
#elif defined(_MSC_VER)
#   define CPP_STANDARD _MSVC_LANG
#endif

#if CPP_STANDARD >= 199711L
#   define HAS_CPP_03 1
#endif
#if CPP_STANDARD >= 201103L
#   define HAS_CPP_11 1
#endif
#if CPP_STANDARD >= 201402L
#   define HAS_CPP_14 1
#endif
#if CPP_STANDARD >= 201703L
#   define HAS_CPP_17 1
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _WIN32

#   ifndef PATH_SPEC
#       define PATH_SPEC '\\'
#   endif

// 控制台代码页改成utf8
#   define INIT_UTF8_TERM(x) UINT x = GetConsoleOutputCP(); SetConsoleOutputCP(65001);
#   define UNINIT_UTF8_TERM(x) SetConsoleOutputCP(x);

// 时间函数改成linux样式
// #   define localtime_r(x, y) localtime_s(y, x)

#else

#   ifndef PATH_SPEC
#       define PATH_SPEC '/'
#   endif
#   define INIT_UTF8_TERM(x) (void)(0);
#   define UNINIT_UTF8_TERM(x) (void)(0);

#endif

#ifdef __cplusplus
}
#endif

#endif // __PLATFORM_H__